package com.chy.order_meal.config;

import com.chy.order_meal.config.interceptor.InterceptorConfig;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.Arrays;
import java.util.List;

@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        List<String> exUrl = Arrays.asList("/user/login", "/user/isLogin", "/user/save");
        registry.addInterceptor(new InterceptorConfig()).addPathPatterns("/**").excludePathPatterns(exUrl);
    }

    @Override
    protected void addCorsMappings(CorsRegistry registry) {

        //registry.addMapping("http://127.0.0.1:9000");
    }
}
